/**
 * Search results handling
 */
var search_videos = {
	
	current_search : null,
	start : 1,
	
	load : function(q) {
		q = escape(q);
		debug.print("search_videos.load [q: " + q + "]");
		if (this.current_search != q) {
			this.start = 1;
			this.current_search = q;
			autodj.source = 'search';
			autodj.initialized = false;
			search_videos_list.clear(this.request);
		} else {
			this.start = this.start + 10;
			this.request();
		}
	},
		
	request : function() {
		debug.print("search_videos.request");
		ui.setSearchStatus('loading');
		$.getJSON("/search/video_q/json?q="+search_videos.current_search+"&start="+search_videos.start, function(data){
			if (ObjectLength(data.videos) == 0) {
				flash.flash("No search", "results");
				ui.setSearchStatus('idle');
				$("#search-next").hide();
			} else {
				search_videos_list.add(data.videos, search_videos.start);
				bind.search_videos_drag();
				ui.setSearchStatus('idle');
			};				
		});
	}			
	
}